package edu.cuit.canary;

import java.util.Scanner;

/**
 * 使用常量计算圆的面积及周长
 */
public class ComputeAreaAndPerimeterWithConstant {
    public static void main(String[] args) {
        //声明常量: final datatype CONSTANT_NAME = value;
        final double PI = 3.14;
        /*
        print: 打印完后不换行,必须接收参数
        println: 打印完后不换行,不接收参数表示打印空行
         */
        System.out.print("请输入圆的半径:");
        Scanner input = new Scanner(System.in);
        double radius = input.nextDouble();
        if(radius >= 0) {
            double area = PI * radius * radius;
            double perimeter = 2 * PI * radius;
            System.out.println("Area = " + area + ";Perimeter = " + perimeter);
        } else
            System.err.println("非法的半径:" + radius);
        input.close();

    }
}
